home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UMacTcp.h < prev    next >
Encoding:
Text File  |  1994-03-16  |  1.8 KB  |  75 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UMacTCP.h
  3.  
  4. #define __UMACTCP__
  5.  
  6. #ifndef __UPTROBJECT__
  7. #include "UPtrObject.h"
  8. #endif
  9.  
  10. #include "TCPPB.h"
  11.  
  12. extern short gMacTcpRefNum;
  13.  
  14. //typedef wdsEntry *wdsEntryPtr;
  15. //typedef rdsEntry *rdsEntryPtr;
  16.  
  17. class TProgress;
  18.  
  19. void InitUMacTCP();
  20. void CloseDownUMacTCP();
  21. pascal void KillMacTCPStuff(); // called from installed patch
  22.  
  23. long MyIP();
  24. long DotName2IP(const CStr255 &name);
  25. void IP2DotName(long ip, CStr255 &name);
  26. void GetMyDotName(CStr255 &myDotName);
  27.  
  28. class PTcpStream : public PPtrObject
  29. {
  30.     public:
  31.         // If any of these are aborted with Failure(0, 0) by TThread,
  32.         // the object should be disposed as the connection is aborted
  33.         void SendData(void *bufferP, long len);
  34.         void GetDataPointer(void *&p, long &bytesReceived);
  35.         void ReceiveSomeData(void *bufferP, long bufferSize, long &bytesReceived);
  36.         
  37.         void OpenConnection(long hostIP, short port); // includes stream
  38.         void CloseConnection(Boolean async = true);
  39.         
  40.         PTcpStream();
  41.         void ITcpStream(long timeoutSecs);
  42.         ~PTcpStream();
  43.     private:
  44.         Boolean fConnectionIsOpen;
  45.         Boolean fStreamIsOpen;
  46.         Ptr fStreamBufferP;
  47.         TCPiopb fStreamPB;
  48.         TCPiopb fOpenPB, fClosePB, fAbortPB;
  49.         TCPiopb fReceivePB, fSendPB;
  50.         TCPiopb fStatusPB;
  51.         StreamPtr fStreamP;
  52.         wdsEntry fWdsEntry[5];
  53.         long fTimeoutTicks, fTimeoutSecs;
  54.         long fHostIP;
  55.         short fHostPort;
  56.         long fMacTCPID;
  57.  
  58.         // only TCPOpenConnection, read&write methods are async
  59.         
  60.         void TCPCreateStream();
  61.         void TCPReleaseStream();
  62.         
  63.         void TCPOpenConnection();
  64.         void TCPCloseConnection(Boolean async);
  65.         void TCPAbortConnection();
  66.         void TCPCloseOrAbortConnection(Boolean async);
  67.         void TCPSendData();
  68.         long TCPNumBytesAvailable();
  69.         void TCPReceiveData(void *bufferP, unsigned short bufferSize,
  70.                                             short &bytesReceived);
  71.  
  72.         void WaitForCompletion(TCPiopb &pb);
  73.         void DebugCheckWds();
  74. };
  75.